﻿using System.Text;
using System.Net;
using SDFL.Helper;

namespace SDFL.Tools.WeatherLib
{
    public class WeatherReport
    {
        private const string __Url = "http://m.weather.com.cn/data/{0}.html";
        public WeatherReport() { }
		public WeatherSimpleInfo weatherinfo { get; set; }
		/// <summary>获取简单天气预报</summary>
		/// <param name="name">城市代码</param>
		/// <returns>天气预报</returns>
        public static WeatherSimpleInfo Get(string code)
		{
			using(WebClient wc = new WebClient()){
				wc.Encoding = Encoding.UTF8;
				var url=string.Format(__Url,code);
				string str = wc.DownloadString(url);
                return SerializationHelper.JsonDeserialize<WeatherReport>(str).weatherinfo;
			}
		}
    }
}
